import React from 'react';
import {
    View,
    Text,
    Image,
    TouchableOpacity,
    StyleSheet
} from 'react-native';
import NavigationUtil from '../navigator/NavigationUtil'
import {screen} from '../public/common';
import color from '../public/widget/color';
import DataStore,{BaseUrl} from '../public/dao/DataStore';
export default class LoanListItem extends React.PureComponent {
    render() {
      let dataStore = new DataStore(); 
      const {infoData} = this.props;
      let items = infoData ? infoData.item:{};
      let mobile = '';
      dataStore.fetchLocalData('USERDATAS').then((json)=>{//查看本地存储
          mobile = json.data.mobile
        }).catch((err)=>{
            console.log(err)
        })
       let params ={};
      return (
        <TouchableOpacity onPress={()=>{
            NavigationUtil.goPage({
                ...infoData, //路由传参
            },'LoanDetail'),
            params.mobile = mobile; 
            params.name = infoData.item.name;
            // let img_url = infoData.item.image_url;
            // if(img_url.indexOf('lessloan') != -1){
            //     console.log('lessloan')
            // }else{
            //     console.log('largeloan')
            // }
            // console.log('klh211',img_url)
            dataStore.fetchData('/webservice/browse',params,'POST','',true,true).then((json)=>{
                if(json.data.errno == 0){
                    console.log(params)
                }
            }).catch((err)=>{
                console.log(err);
            })
        }}>
          <View style={styles.itemsview}>
            <View>
                <View style={styles.leftitemsTop}>
                    <Image style={styles.itemsImage} source={{uri:BaseUrl+'/'+items.image_url}}/>
                    <Text style={styles.itemstoptext}>{items.name}</Text>
                    <View style={styles.itemstoptextBorder}>
                        <Text style={styles.itemstoptextBorderText}>最高{items.max_amount}</Text>
                    </View>
                </View>
                <Text style={styles.numText}>{items.scope}</Text>
                <Text>额度范围（元）</Text>
            </View>
            <View style={styles.itemsRight}>
                <Text style={styles.rightText}>日利率{items.interest_rate}</Text>
                <Text numberOfLines={1} style={{width:100}}>{items.repay_term}</Text>
            </View>
          </View>
        </TouchableOpacity>
      );
    }
}
const styles = StyleSheet.create({
    itemsview:{
        flexDirection:'row',
        justifyContent:'space-between',
        width:screen.width,
        borderTopWidth:1,
        borderTopColor:color.border,
        paddingTop: 10,
        paddingBottom: 10,
        paddingLeft: 15,
        paddingRight: 15,
    },
    leftitemsTop:{
        flexDirection:'row',
        alignItems:'center',
        marginBottom: 10,
    },
    itemsImage:{
        width: 20,
        height: 20,
    },
    itemstoptext: {
        marginRight:5,
        marginLeft: 5,
    },
    itemstoptextBorder:{
        borderWidth: 1,
        borderColor:'#fe7c1a',
    },
    itemstoptextBorderText:{
        color:'#fe7c1a'
    },
    numText:{
        color:'#fe7c1a',
        fontSize: 23,
        marginBottom:10,
    },
    itemsRight:{
        width:100,
        marginTop:35,
        marginRight:50
    },
    rightText:{
        marginBottom:10,
    }
});